{
	"info": {
		"_postman_id": "c874ffbb-1644-47aa-a833-f494b9663634",
		"name": "Single Job",
		"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json",
		"_exporter_id": "4117505"
	},
	"item": [
		{
			"name": "1 Session Login",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"exec": [
							""
						],
						"type": "text/javascript",
						"packages": {}
					}
				},
				{
					"listen": "test",
					"script": {
						"exec": [
							"const response = JSON.parse(responseBody)",
							"pm.collectionVariables.set(\"JWT_TOKEN\", response.session_token);",
							"pm.collectionVariables.set(\"USER_ID\", response.user_id);",
							""
						],
						"type": "text/javascript",
						"packages": {}
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json"
					},
					{
						"key": "x-cardsavr-trace",
						"value": "{\"key\": \"my_trace\"}"
					},
					{
						"key": "x-cardsavr-session-jwt",
						"value": "null",
						"type": "text",
						"disabled": true
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"password\": \"{{PASSWORD}}\",\n    \"username\": \"{{USERNAME}}\"\n}"
				},
				"url": "https://api.{{CARDSAVR-INSTANCE}}.cardsavr.io:{{PORT}}/session/login"
			},
			"response": []
		},
		{
			"name": "2 Merchants",
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "x-cardsavr-trace",
						"value": "{\"key\": \"my_trace\"}"
					},
					{
						"key": "x-cardsavr-session-jwt",
						"value": "{{JWT_TOKEN}}",
						"type": "text"
					},
					{
						"key": "x-cardsavr-paging",
						"value": "{\"page\": \"1\", \"page_length\": \"10000000\"} ",
						"type": "default"
					}
				],
				"url": {
					"raw": "https://api.{{CARDSAVR-INSTANCE}}.cardsavr.io:{{PORT}}/merchant_sites?tags=synthetic,demo,disabled,prod&image_widths=128,32&top_hosts=amazon.com,apple.com,audible.com,hulu.com,netflix.com,spotify.com,target.com,uber.com,venmo.com,walgreens.com,walmart.com&exclude_hosts=null",
					"protocol": "https",
					"host": [
						"api",
						"{{CARDSAVR-INSTANCE}}",
						"cardsavr",
						"io"
					],
					"port": "{{PORT}}",
					"path": [
						"merchant_sites"
					],
					"query": [
						{
							"key": "tags",
							"value": "synthetic,demo,disabled,prod"
						},
						{
							"key": "image_widths",
							"value": "128,32"
						},
						{
							"key": "top_hosts",
							"value": "amazon.com,apple.com,audible.com,hulu.com,netflix.com,spotify.com,target.com,uber.com,venmo.com,walgreens.com,walmart.com"
						},
						{
							"key": "exclude_hosts",
							"value": "null"
						}
					]
				}
			},
			"response": []
		},
		{
			"name": "3.1 POST Job",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"const response = JSON.parse(responseBody)",
							"pm.collectionVariables.set(\"JOB_ID\", response.id);",
							"pm.collectionVariables.set(\"CARDHOLDER_ID\", response.cardholder_id);",
							"pm.collectionVariables.set(\"ACCOUNT_ID\", response.account_id);",
							"let env_id;",
							"if (response[\"credential_requests\"].filter(msg => {",
							"    if (msg.envelope_id) {",
							"        env_id = msg.envelope_id;",
							"        return true;",
							"    }",
							"})) {",
							"    if (env_id) {",
							"        pm.collectionVariables.set(\"ENVELOPE_ID\", env_id);",
							"    }",
							"}",
							""
						],
						"type": "text/javascript",
						"packages": {}
					}
				},
				{
					"listen": "prerequest",
					"script": {
						"exec": [
							"pm.collectionVariables.set(\"CARDHOLDER_CUID\", \"{{$timestamp}}\");",
							"pm.environment.set(\"randomNumber\", Math.floor(Math.random() * 100) + 1);//pm.collectionVariables.set(\"CARDHOLDER_CUID\", \"1234123416\");",
							"pm.collectionVariables.set(\"CARDHOLDER_SAFE_KEY\", \"MBNL8Chib96EYdXNt3+etblMg2RAHUYM1d7ScSd8nf8=\");"
						],
						"type": "text/javascript",
						"packages": {}
					}
				}
			],
			"protocolProfileBehavior": {
				"disabledSystemHeaders": {
					"content-type": true
				}
			},
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json"
					},
					{
						"key": "x-cardsavr-financial-institution",
						"value": "garbage_fi",
						"type": "text",
						"disabled": true
					},
					{
						"key": "x-cardsavr-trace",
						"value": "{\"key\": \"my_trace\"}"
					},
					{
						"key": "x-cardsavr-session-jwt",
						"value": "{{JWT_TOKEN}}"
					},
					{
						"key": "x-cardsavr-hydration",
						"value": "[\"credential_requests\", \"card\", \"card.address\",\"cardholder\"]",
						"type": "text"
					},
					{
						"key": "x-cardsavr-cardholder-safe-key",
						"value": "{{CARDHOLDER_SAFE_KEY}}",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\r\n  \"status\": \"REQUESTED\",\r\n  \"queue_name_override1\" : \"vbs_localstack_queue\",\r\n  \"user_data_settings\":\r\n  {\r\n    \"cache_writer\" :\r\n    {\r\n       \"tts\": 86400000,\r\n       \"active\": true\r\n    },\r\n    \"global_cookie_writer\" : {\r\n        \"ttl\": 86400000,\r\n        \"active\": false\r\n    },\r\n    \"global_cookie_reader\" : {\r\n        \"active\" : false\r\n    },\r\n    \"user_cookie_reader_writer\" : {\r\n        \"active\" : true\r\n    }\r\n  },\r\n  \"cardholder\":\r\n  {\r\n    \"cuid\":\"{{CARDHOLDER_CUID}}\",\r\n    \"type\":\"persistent_all\"\r\n  },\r\n  \"card\":\r\n    {\r\n      \"cardholder_ref\": {\r\n        \"cuid\": \"{{CARDHOLDER_CUID}}\"\r\n      },\r\n      \"par\":\"0000000000000000000{{CARDHOLDER_CUID}}\",\r\n      \"pan\":\"4111111111111111\",\r\n      \"cvv\":\"123\",\r\n      \"expiration_month\":\"12\",\r\n      \"expiration_year\":\"24\",\r\n      \"name_on_card\":\"Gary Tomlinson\",\r\n      \"first_name\":\"Gary\",\r\n      \"last_name\":\"Tomlinson\",\r\n      \"address\":\r\n        {\r\n          \"cardholder_ref\": {\r\n            \"cuid\": \"{{CARDHOLDER_CUID}}\"\r\n          },\r\n          \"address1\":\"16969 65th LN first_name\",\r\n          \"address2\":\"\",\r\n          \"city\":\"Kenmore\",\r\n          \"subnational\":\"WA\",\r\n          \"postal_code\":\"98028\",\r\n          \"postal_other\":\"\",\r\n          \"country\":\"USA\",\r\n          \"is_primary\": true,\r\n          \"first_name\":\"Gary\",\r\n          \"last_name\":\"Tomlinson\",\r\n          \"email\":\"gtomlinson@strivve.com\",\r\n          \"phone_number\":\"4255030881\"\r\n        }\r\n    },\r\n  \"account\":\r\n    {\r\n      \"cardholder_ref\": {\r\n        \"cuid\": \"{{CARDHOLDER_CUID}}\"\r\n      },\r\n      \"merchant_site_id\":1,\r\n      \"account_link\": {\r\n            \"username\": \"{{INITIAL_USERNAME}}\",\r\n            \"password\": \"{{INITIAL_PASSWORD}}\"\r\n        }\r\n    }\r\n}"
				},
				"url": "https://api.{{CARDSAVR-INSTANCE}}.cardsavr.io:{{PORT}}/place_card_on_single_site_jobs"
			},
			"response": []
		},
		{
			"name": "3.2 POST Job w/pesistent creds",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"exec": [
							"",
							"pm.collectionVariables.set(\"CARDHOLDER_SAFE_KEY\", \"MBNL8Chib96EYdXNt3+etblMg2RAHUYM1d7ScSd8nf8=\");"
						],
						"type": "text/javascript"
					}
				},
				{
					"listen": "test",
					"script": {
						"exec": [
							"const response = JSON.parse(responseBody)",
							"pm.collectionVariables.set(\"JOB_ID\", response.id);",
							"pm.collectionVariables.set(\"CARDHOLDER_ID\", response.cardholder_id);",
							"pm.collectionVariables.set(\"ACCOUNT_ID\", response.account_id);",
							""
						],
						"type": "text/javascript"
					}
				}
			],
			"protocolProfileBehavior": {
				"disabledSystemHeaders": {
					"content-type": true
				}
			},
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json"
					},
					{
						"key": "x-cardsavr-financial-institution",
						"value": "garbage_fi",
						"type": "text",
						"disabled": true
					},
					{
						"key": "x-cardsavr-trace",
						"value": "{\"key\": \"my_trace\"}"
					},
					{
						"key": "x-cardsavr-session-jwt",
						"value": "{{JWT_TOKEN}}"
					},
					{
						"key": "x-cardsavr-hydration",
						"value": "[\"credential_requests\"]",
						"type": "text"
					},
					{
						"key": "x-cardsavr-cardholder-safe-key",
						"value": "{{CARDHOLDER_SAFE_KEY}}",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\r\n    \"custom_data\": {\r\n        \"job_foo\": \"foo\",\r\n        \"job_bar\": \"job_bar\"\r\n    },\r\n    \"cardholder\": {\r\n        \"cuid\": \"{{CARDHOLDER_CUID}}\",\r\n        \"type\": \"persistent_creds\"\r\n    },\r\n    \"card\": {\r\n        \"customer_key\": \"0000000000000000000{{CARDHOLDER_CUID}}\"\r\n    },\r\n    \"account_id\": {{ACCOUNT_ID}}\r\n}"
				},
				"url": "https://api.{{CARDSAVR-INSTANCE}}.cardsavr.io:{{PORT}}/place_card_on_single_site_jobs"
			},
			"response": []
		},
		{
			"name": "4-1 Get Job",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"const response = JSON.parse(responseBody)",
							"let env_id = null;",
							"if (response[\"credential_requests\"].filter(msg => {",
							"    if (msg.envelope_id) {",
							"        env_id = msg.envelope_id;",
							"        return true;",
							"    }",
							"})) {",
							"    pm.collectionVariables.set(\"ENVELOPE_ID\", env_id);",
							"}",
							""
						],
						"type": "text/javascript",
						"packages": {}
					}
				}
			],
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json",
						"description": "x-cq"
					},
					{
						"key": "x-cardsavr-trace",
						"value": "{\"key\": \"my_trace\"}"
					},
					{
						"key": "x-cardsavr-session-jwt",
						"value": "{{JWT_TOKEN}}",
						"type": "text"
					},
					{
						"key": "x-cardsavr-hydration",
						"value": "[\"credential_requests\", \"card\",\"card.address\",\"cardholder\"]",
						"type": "text"
					}
				],
				"url": "https://api.{{CARDSAVR-INSTANCE}}.cardsavr.io:{{PORT}}/place_card_on_single_site_jobs/{{JOB_ID}}"
			},
			"response": []
		},
		{
			"name": "4-2 Get Job Status (messages endpoint)",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"const response = JSON.parse(responseBody)",
							"let env_id = null;",
							"if (response.some(msg => {",
							"    if (msg.envelope_id) {",
							"        env_id = msg.envelope_id;",
							"        return true;",
							"    }",
							"})) {",
							"    pm.collectionVariables.set(\"ENVELOPE_ID\", env_id);",
							"}",
							""
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json"
					},
					{
						"key": "x-cardsavr-trace",
						"value": "{\"key\": \"my_trace\"}"
					},
					{
						"key": "x-cardsavr-session-jwt",
						"value": "{{JWT_TOKEN}}",
						"type": "text"
					}
				],
				"url": {
					"raw": "https://api.{{CARDSAVR-INSTANCE}}.cardsavr.io:{{PORT}}/messages/place_card_on_single_site_jobs/{{JOB_ID}}?",
					"protocol": "https",
					"host": [
						"api",
						"{{CARDSAVR-INSTANCE}}",
						"cardsavr",
						"io"
					],
					"port": "{{PORT}}",
					"path": [
						"messages",
						"place_card_on_single_site_jobs",
						"{{JOB_ID}}"
					],
					"query": [
						{
							"key": "",
							"value": null
						}
					]
				}
			},
			"response": []
		},
		{
			"name": "4-3 Get Cardholder Jobs Status (messages endpoint)",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"const response = JSON.parse(responseBody)",
							"let env_id = null;",
							"if (response.some(msg => {",
							"    if (msg.envelope_id) {",
							"        env_id = msg.envelope_id;",
							"        return true;",
							"    }",
							"})) {",
							"    pm.collectionVariables.set(\"ENVELOPE_ID\", env_id);",
							"}",
							""
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json"
					},
					{
						"key": "x-cardsavr-trace",
						"value": "{\"key\": \"my_trace\"}"
					},
					{
						"key": "x-cardsavr-session-jwt",
						"value": "{{JWT_TOKEN}}",
						"type": "text"
					}
				],
				"url": {
					"raw": "https://api.{{CARDSAVR-INSTANCE}}.cardsavr.io:{{PORT}}/messages/place_card_on_single_site_jobs/{{JOB_ID}}?=",
					"protocol": "https",
					"host": [
						"api",
						"{{CARDSAVR-INSTANCE}}",
						"cardsavr",
						"io"
					],
					"port": "{{PORT}}",
					"path": [
						"messages",
						"place_card_on_single_site_jobs",
						"{{JOB_ID}}"
					],
					"query": [
						{
							"key": "",
							"value": ""
						}
					]
				}
			},
			"response": []
		},
		{
			"name": "5-1 Resubmit Credentials",
			"request": {
				"method": "PUT",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json"
					},
					{
						"key": "x-cardsavr-trace",
						"value": "{\"key\": \"my_trace\"}"
					},
					{
						"key": "x-cardsavr-envelope-id",
						"value": "{{ENVELOPE_ID}}",
						"type": "text"
					},
					{
						"key": "x-cardsavr-session-jwt",
						"value": "{{JWT_TOKEN}}",
						"type": "text"
					},
					{
						"key": "x-cardsavr-cardholder-safe-key",
						"value": "{{CARDHOLDER_SAFE_KEY}}",
						"type": "text",
						"disabled": true
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\r\n    \"account\": {\r\n        \"account_link\": {\r\n            \"username\": \"good_email\",\r\n            \"password\": \"tfa\"\r\n        }\r\n    }\r\n}"
				},
				"url": "https://api.{{CARDSAVR-INSTANCE}}.cardsavr.io:{{PORT}}/place_card_on_single_site_jobs/{{JOB_ID}}"
			},
			"response": []
		},
		{
			"name": "5-2 Resubmit Credentials (via account)",
			"request": {
				"method": "PUT",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json"
					},
					{
						"key": "x-cardsavr-trace",
						"value": "{\"key\": \"my_trace\"}"
					},
					{
						"key": "x-cardsavr-envelope-id",
						"value": "{{ENVELOPE_ID}}",
						"type": "text"
					},
					{
						"key": "x-cardsavr-session-jwt",
						"value": "{{JWT_TOKEN}}",
						"type": "text"
					},
					{
						"key": "x-cardsavr-",
						"value": "",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\r\n    \"account\": {\r\n        \"username\": \"good_email\",\r\n        \"password\": \"security\"\r\n    }\r\n}"
				},
				"url": "https://api.{{CARDSAVR-INSTANCE}}.cardsavr.io:{{PORT}}/place_card_on_single_site_jobs/{{JOB_ID}}"
			},
			"response": []
		},
		{
			"name": "5-3 Resubmit Email & Phone",
			"request": {
				"method": "PUT",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json"
					},
					{
						"key": "x-cardsavr-trace",
						"value": "{\"key\": \"my_trace\"}"
					},
					{
						"key": "x-cardsavr-envelope-id",
						"value": "{{ENVELOPE_ID}}",
						"type": "text"
					},
					{
						"key": "x-cardsavr-session-jwt",
						"value": "{{JWT_TOKEN}}",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\r\n    \"account\": {\r\n        \"account_link\" : {\r\n            \"email\": \"test@test.com\",\r\n            \"phone_number\": \"5555555555\"\r\n        }\r\n    }\r\n}"
				},
				"url": "https://api.{{CARDSAVR-INSTANCE}}.cardsavr.io:{{PORT}}/place_card_on_single_site_jobs/{{JOB_ID}}"
			},
			"response": []
		},
		{
			"name": "5-4 Submit TFA",
			"request": {
				"method": "PUT",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json"
					},
					{
						"key": "x-cardsavr-trace",
						"value": "{\"key\": \"my_trace\"}"
					},
					{
						"key": "x-cardsavr-envelope-id",
						"value": "{{ENVELOPE_ID}}",
						"type": "text"
					},
					{
						"key": "x-cardsavr-session-jwt",
						"value": "{{JWT_TOKEN}}",
						"type": "text"
					},
					{
						"key": "x-cardsavr-cardholder-safe-key",
						"value": "{{CARDHOLDER_SAFE_KEY}}",
						"type": "text",
						"disabled": true
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\r\n    \"account\": {\r\n        \"account_link\": {\r\n            \"tfa\" : \"1234\"\r\n        }\r\n    }\r\n}"
				},
				"url": "https://api.{{CARDSAVR-INSTANCE}}.cardsavr.io:{{PORT}}/place_card_on_single_site_jobs/{{JOB_ID}}"
			},
			"response": []
		},
		{
			"name": "5-5 Submit Security Questions",
			"request": {
				"method": "PUT",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json"
					},
					{
						"key": "x-cardsavr-trace",
						"value": "{\"key\": \"my_trace\"}"
					},
					{
						"key": "x-cardsavr-envelope-id",
						"value": "{{ENVELOPE_ID}}",
						"type": "text"
					},
					{
						"key": "x-cardsavr-session-jwt",
						"value": "{{JWT_TOKEN}}",
						"type": "text"
					},
					{
						"key": "x-cardsavr-cardholder-safe-key",
						"value": "{{CARDHOLDER_SAFE_KEY}}",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\r\n    \"account\": {\r\n        \"account_link\" : {\r\n            \"security_1\": \"Max\",\r\n            \"security_2\": \"Smith\"\r\n        }\r\n    }\r\n}"
				},
				"url": "https://api.{{CARDSAVR-INSTANCE}}.cardsavr.io:{{PORT}}/place_card_on_single_site_jobs/{{JOB_ID}}"
			},
			"response": []
		},
		{
			"name": "6 Get Card Placement Result by cardholder cuid",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							""
						],
						"type": "text/javascript",
						"packages": {}
					}
				}
			],
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json",
						"description": "x-cq"
					},
					{
						"key": "x-cardsavr-trace",
						"value": "{\"key\": \"my_trace\"}"
					},
					{
						"key": "x-cardsavr-session-jwt",
						"value": "{{JWT_TOKEN}}",
						"type": "text"
					},
					{
						"key": "x-cardsavr-hydration",
						"value": "[\"credential_requests\"]",
						"type": "text"
					}
				],
				"url": {
					"raw": "https://api.{{CARDSAVR-INSTANCE}}.cardsavr.io:{{PORT}}/card_placement_results?cuids={{CARDHOLDER_CUID}}",
					"protocol": "https",
					"host": [
						"api",
						"{{CARDSAVR-INSTANCE}}",
						"cardsavr",
						"io"
					],
					"port": "{{PORT}}",
					"path": [
						"card_placement_results"
					],
					"query": [
						{
							"key": "cuids",
							"value": "{{CARDHOLDER_CUID}}"
						}
					]
				}
			},
			"response": []
		},
		{
			"name": "7 End Session",
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json"
					},
					{
						"key": "x-cardsavr-trace",
						"value": "{\"key\": \"my_trace\"}"
					},
					{
						"key": "x-cardsavr-session-jwt",
						"value": "{{JWT_TOKEN}}",
						"type": "text"
					}
				],
				"url": "https://api.{{CARDSAVR-INSTANCE}}.cardsavr.io:{{PORT}}/session/end"
			},
			"response": []
		}
	],
	"event": [
		{
			"listen": "prerequest",
			"script": {
				"type": "text/javascript",
				"exec": [
					""
				]
			}
		},
		{
			"listen": "test",
			"script": {
				"type": "text/javascript",
				"exec": [
					""
				]
			}
		}
	],
	"variable": [
		{
			"key": "CARDHOLDER_UNIQUE_KEY",
			"value": "mrfy69"
		},
		{
			"key": "JOB_ID",
			"value": 163
		},
		{
			"key": "ENVELOPE_ID",
			"value": null
		},
		{
			"key": "JWT_TOKEN",
			"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI1MjdlNWE1OC02YjBlLTRmZTItYTNlYS0xM2FmNzFlYzQ1MzUiLCJpc3MiOiJhcGkubG9jYWxob3N0LmNhcmRzYXZyLmlvIiwiYXVkIjoiYXBpLmxvY2FsaG9zdC5jYXJkc2F2ci5pbyIsImlhdCI6MTYxODMzMjY5N30.TA76i98OMNwxs7kjs_K52WmftDdRuUJU68oVgrM6dOg"
		},
		{
			"key": "CARDHOLDER_CUID",
			"value": "{{$timestamp}}"
		},
		{
			"key": "CARDHOLDER_ID",
			"value": 230
		},
		{
			"key": "ACCOUNT_ID",
			"value": ""
		},
		{
			"key": "CARDHOLDER_SAFE_KEY",
			"value": ""
		},
		{
			"key": "USER_ID",
			"value": ""
		},
		{
			"key": "JWT_TOKEN2",
			"value": ""
		},
		{
			"key": "CUID",
			"value": ""
		}
	]
}